package com.example.easy.Service.Impl;

import com.example.easy.Dto.Notice;
import com.example.easy.Dto.Visitor;
import com.example.easy.Service.myservice.NoticeServise;
import com.example.easy.Service.myservice.VisitorServise;
import com.example.easy.mapper.NoticeMapper;
import com.example.easy.mapper.VisitorMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NoviceServiselmpl implements NoticeServise {

    @Autowired
    NoticeMapper noticeMapper;

    //插入
    @Override
    public int insNotice(Notice notice) {

      return noticeMapper.insNotice(notice);

    }

    //修改
    @Override
    public int updateNotice(Notice notice) {
        if (noticeMapper.selectnotice(notice.getNumber()) != null) {
            noticeMapper.updateNotice(notice);
            return 1;
        } else return 0;
    }
//删除
    @Override
    public int deleteNotice(int number) {
        if (noticeMapper.selectnotice(number) != null) {
            noticeMapper.deleteNotice(number);
            return 1;
        } else return 0;
    }
//查看
    @Override
    public Notice selectnotice(int number) {
        if (noticeMapper.selectnotice(number) != null) {
            return noticeMapper.selectnotice(number);
        } else {
            return null;
        }
    }

    @Override
    public List<Notice> selectall() {

        return noticeMapper.selectall();
    }
}
